import {emit} from 'network/request.js'
export function login(username,password){
  let info={}
  if(username.indexOf("@")!=-1){
    info={
      email:username,
      password:password
    }
  }
  else{
    info={
      tel:username,
      password:password
    }
  }
  console.log('post',info);
  return emit({
    method:"post",
    url:'/login',
    headers:{
      'content-type':'application/json'  //如果写成contentType会报错
    },
    data:JSON.stringify(info)
  })
}


export function register(user){
  console.log('post',user)
  return emit({
    method:"post",
    url:'/register',
    headers:{
      'content-type':'application/json'  //如果写成contentType会报错
    },
    data:JSON.stringify(user)
  })
}


export function changeUser(user){
  console.log('post',user)
  return emit({
    method:"post",
    url:'/changeUser',
    headers:{
      'content-type':'application/json'  //如果写成contentType会报错
    },
    data:JSON.stringify(user)
  })
}
